#!/usr/bin/env python3
"""
生成ICO格式图标文件
"""

from PIL import Image
import os

def create_ico():
    """将PNG图标转换为ICO格式"""
    icons_dir = "/Users/ethan/Codes/longimagereader/icons"

    # 读取主图标
    main_icon_path = os.path.join(icons_dir, "app.png")
    if not os.path.exists(main_icon_path):
        print("❌ 错误：找不到主图标文件 app.png")
        return

    main_icon = Image.open(main_icon_path)

    # ICO需要的尺寸
    ico_sizes = [16, 32, 48, 64, 128, 256]

    # 为ICO格式准备多个尺寸的图标
    icon_images = []
    for size in ico_sizes:
        resized_icon = main_icon.resize((size, size), Image.Resampling.LANCZOS)
        icon_images.append(resized_icon)

    # 保存为ICO格式
    ico_path = os.path.join(icons_dir, "app.ico")
    main_icon.save(ico_path, format='ICO', sizes=[(size, size) for size in ico_sizes])

    print(f"✅ ICO图标已生成: {ico_path}")
    print(f"   包含尺寸: {', '.join([f'{size}x{size}' for size in ico_sizes])}")

if __name__ == "__main__":
    create_ico()